using System;
using System.IO;

public static class Logger
{
    private static readonly string logPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "logs");
    
    public static void LogError(string message, Exception ex)
    {
        try
        {
            if (!Directory.Exists(logPath))
                Directory.CreateDirectory(logPath);
                
            var logFile = Path.Combine(logPath, $"error_{DateTime.Now:yyyyMMdd}.log");
            var logMessage = $"[{DateTime.Now:yyyy-MM-dd HH:mm:ss}] {message}";
            if (ex != null)
                logMessage += $"\n{ex}";
            logMessage += "\n";
            
            File.AppendAllText(logFile, logMessage);
        }
        catch { }
    }
}
